/*
 * Copyright (c) 2005, The haXe Project Contributors
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */

 
package hxphp.oo.gd;

import hxphp.oo.gd.GDImage;

class GDDrawing 
{
	public var resource:GDResource;
	
	public function new(resource:GDResource) 
	{
		this.resource = resource;
	}
	
	/** Activate the fast drawing antialiased methods for lines and wired polygons */
	public function antiAlias( on:Bool ):Bool
	{
		return untyped __call__("imagealphablending ", resource, on);
	}
	
	/** draws a partial ellipse centered at cx, cy (top left is 0, 0) in the image represented by image. W and h specifies the ellipse's width and height respectively while the start and end points are specified in degrees indicated by the s and e arguments. 0Â° is located at the three-o'clock position, and the arc is drawn clockwise.  */
	public function arc( cx:Int, cy:Int, w:Int, h:Int, s:Int, e:Int, color:Int):Bool
	{
		return untyped __call__("imagearc ", resource, cx, cy, w, h, s, e, color );
	}
	
	/** draws an ellipse centered at cx, cy (top left is 0, 0) in the image represented by image. W and h specifies the ellipse's width and height respectively. The color of the ellipse is specified by color */
	public function ellipse(cx:Int, cy:Int, w:Int, h:Int, color:Int ):Bool
	{
		return untyped __call__("imageellipse", resource, cx, cy, w, h, color);
	}
	
	/** performs a flood fill starting at coordinate x, y (top left is 0, 0) with color color in the image image */
	public function fill( x:Int, y:Int, color:Int):Bool
	{
		return untyped __call__("imagefill", resource, x, y, color);
	}
	
	/** draws a partial ellipse centered at cx, cy (top left is 0, 0) in the image represented by image. */
	public function filledArc( cx:Int, cy:Int, w:Int, h:Int, s:Int, e:Int, color:Int, style:Int):Bool
	{
		return untyped __call__("imagefilledarc", resource, cx, cy, w, h, s, e, color, style);
	}
	
	/** draws an ellipse centered at cx, cy (top left is 0, 0) in the image represented by image. W and h specifies the ellipse's width and height respectively. The ellipse is filled using color */
	public function filledEllipse( cx:Int, cy:Int, w:Int, h:Int, color:Int):Bool
	{
		return untyped __call__("imagefilledellipse", resource, cx, cy, w, h, color);
	}

	/** creates a filled polygon in image image. points is an array containing the x and y co-ordinates of the polygons vertices consecutively. The parameter num_points is the total number of vertices, which must be larger than 3.  */
	public function filledPolygon( points:Array<Dynamic>, num_points:Int, color:Int):Bool
	{
		return untyped __call__("imagefilledpolygon", resource, points, num_points);
	}
	
	/** creates a filled rectangle of color color in image image starting at upper left coordinates x1, y1 and ending at bottom right coordinates x2, y2. 0, 0 is the top left corner of the image. */
	public function filledRectangle( x1:Int, y1:Int, x2:Int, y2:Int, color:Int):Bool
	{
		return untyped __call__("imagefilledrectangle", resource, x1, y1, x2, y2, color);
	}
	
	
	
	/** performs a flood fill whose border color is defined by border. The starting point for the fill is x, y (top left is 0, 0) and the region is filled with color color. */
	public function fillToBorder( x:Int, y:Int, border:Int, color:Int):Bool
	{
		return untyped __call__("imagefilltoborder", resource, x, y, border, color);
	}
	
	/** draws a line from x1, y1 to x2, y2 (top left is 0, 0) in image image of color color. */
	public function line ( x1:Int, y1:Int, x2:Int, y2:Int, color:Int ):Bool
	{
		return untyped __call__("imageline", resource, x1, y1, x2, y2, color);
	}
	
	/** creates a polygon in image  */
	public function polygon ( points:Array<Dynamic>, num_points:Int, color:Int ):Bool
	{
		return untyped __call__("imagepolygon", resource, points, num_points, color);
	}
	
	/** creates a rectangle of color col in image image starting at upper left coordinate x1, y1 and ending at bottom right coordinate x2, y2. 0, 0 is the top left corner of the image.   */
	public function rectangle ( x1:Int, y1:Int, x2:Int, y2:Int, col:Int ):Bool
	{
		return untyped __call__("imagerectangle", resource, x1, y1, x2, y2, col );
	}
	
	/** Set the brush image for line drawing */
	public function setBrush ( brush:GDImage ):Bool
	{
		
		return untyped __call__("imageSetBrush", resource, brush.resource );
	}
	
	/** Set the brush image for line drawing */
	public function setPixel ( x:Int, y:Int, color:Int ):Bool
	{
		return untyped __call__("imagesetpixel", resource, x, y, color );
	}
	
	/** Set the style for line drawing */
	public function setStyle ( style:Array<Dynamic> ):Bool
	{
		return untyped __call__("imagesetstyle", resource, style );
	}
	
	/** Set the style for line drawing */
	public function setThickness ( thickness:Int ):Bool
	{
		return untyped __call__("imagesetthickness", resource, thickness );
	}
	
	/** Set the tile image for filling */
	public function setTile ( tile:GDImage ):Bool
	{
		return untyped __call__("imagesettile", resource, tile.resource );
	}
}